package com.maliankeji.mybatisflexdemo;

import com.mybatisflex.core.audit.AuditManager;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;

@SpringBootApplication
@MapperScan("com.maliankeji.mybatisflexdemo.mapper")
@Configuration
public class MybatisFlexDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(MybatisFlexDemoApplication.class, args);
    }

    private static final Logger LOGGER = LoggerFactory.getLogger("mybatis-flex-sql");

    public MybatisFlexDemoApplication() {
        AuditManager.setAuditEnable(true);

        AuditManager.setMessageCollector(auditMessage ->
                LOGGER.info("SQL语句：「{}」，SQL耗时：{}ms",auditMessage.getFullSql(),auditMessage.getElapsedTime()));
    }

}
